import { Injectable, NestInterceptor, ExecutionContext, CallHandler, HttpStatus } from '@nestjs/common';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { Request, Response } from 'express';
@Injectable()
export class StatusCodeInterceptor implements NestInterceptor {
    intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
        return next.handle().pipe(
            map((data) => {
                const response = context.switchToHttp().getResponse<Response>();
                response.setHeader('Cache-Control', 'no-store')
                response.status(HttpStatus.OK); // 设置状态码为 200
                return data;
            }),
        );
    }
}